package org.wangyuhang;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.*;

import javax.sql.DataSource;

@Configuration
@ComponentScan("org.wangyuhang")
@PropertySource({"jdbc.properties"}) /*也可以写成 @PropertySource({"classpath:jdbc.properties"})*/
@Import(jdbcConfig.class)
public class SpringConfig {

    /*添加@Bean 表示该方法的返回值是一个Bean*/
    /*不推荐在SpringConfig内写*/
/*    @Bean
    public DataSource getDataSource(){
        DruidDataSource dataSource=new DruidDataSource();
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/test");
        dataSource.setUsername("root");
        dataSource.setPassword("wangyuhang");
        return dataSource;
    }*/
}
